﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Supersense.db;
using System.Data;
using LitJson;

public partial class admin_product_ajaxcategory : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string upid = Request.QueryString["upid"];
        Crud modelCategory = new Crud("ss_category", "id");
        DataTable dt = modelCategory.fList("type='product' and upid=" + upid, "", "", "");
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        JsonWriter writer = new JsonWriter(sb);
        writer.WriteArrayStart();
        if (dt != null)
        {
            foreach (DataRow dr in dt.Rows)
            {
                writer.WriteObjectStart();
                writer.WritePropertyName("id");
                writer.Write(dr["id"].ToString().Trim());
                writer.WritePropertyName("name");
                writer.Write(dr["name"].ToString().Trim());
                writer.WriteObjectEnd();
            }
        }
        else
        {
        }

        writer.WriteArrayEnd();
        Response.Write(sb.ToString());
    }
}
